package com.rose.service;

import com.rose.entity.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {


    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(Long deptno) {
                return new Dept().setDeptno(deptno)
                                 .setDname("id=>"+deptno+"，不存在该用户,这个id不存在--@hystrix服务降级")
                                 .setDbSource("无数据");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public int addDept(Dept dept) {
                return 0;
            }
        };
    }
}
